/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package controlacciones.ejb3.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author vanessa
 */
@Entity
@Table(name = "tb_metas")
@NamedQueries({
    @NamedQuery(name = "TbMetas.findAll", query = "SELECT t FROM TbMetas t"),
    @NamedQuery(name = "TbMetas.findByValor", query = "SELECT t FROM TbMetas t WHERE t.valor = :valor"),
    @NamedQuery(name = "TbMetas.findByAno", query = "SELECT t FROM TbMetas t WHERE t.tbMetasPK.ano = :ano"),
    @NamedQuery(name = "TbMetas.findByMes", query = "SELECT t FROM TbMetas t WHERE t.tbMetasPK.mes = :mes"),
    @NamedQuery(name = "TbMetas.findByCodTipoAccion", query = "SELECT t FROM TbMetas t WHERE t.tbMetasPK.codTipoAccion = :codTipoAccion")})
public class TbMetas implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TbMetasPK tbMetasPK;
    @Column(name = "valor")
    private BigDecimal valor;
    @JoinColumn(name = "cod_tipo_accion", referencedColumnName = "cod_tipo_accion", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private TbTipoAccion tbTipoAccion;

    public TbMetas() {
    }

    public TbMetas(TbMetasPK tbMetasPK) {
        this.tbMetasPK = tbMetasPK;
    }

    public TbMetas(String ano, String mes, int codTipoAccion) {
        this.tbMetasPK = new TbMetasPK(ano, mes, codTipoAccion);
    }

    public TbMetasPK getTbMetasPK() {
        return tbMetasPK;
    }

    public void setTbMetasPK(TbMetasPK tbMetasPK) {
        this.tbMetasPK = tbMetasPK;
    }

    public BigDecimal getValor() {
        return valor;
    }

    public void setValor(BigDecimal valor) {
        this.valor = valor;
    }

    public TbTipoAccion getTbTipoAccion() {
        return tbTipoAccion;
    }

    public void setTbTipoAccion(TbTipoAccion tbTipoAccion) {
        this.tbTipoAccion = tbTipoAccion;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tbMetasPK != null ? tbMetasPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TbMetas)) {
            return false;
        }
        TbMetas other = (TbMetas) object;
        if ((this.tbMetasPK == null && other.tbMetasPK != null) || (this.tbMetasPK != null && !this.tbMetasPK.equals(other.tbMetasPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "controlacciones.ejb3.entity.TbMetas[tbMetasPK=" + tbMetasPK + "]";
    }

}
